import { loginAPI } from '@/api'
import { getToken } from '@/utils/auth'
export default {
  namespaced: true,
  state: {
    loginToken: getToken() || ''
  },
  mutations: {
    LOGIN_TOKEN(state, newToken) {
      state.loginToken = newToken
      console.log(state.loginToken)
    }
  },
  actions: {
    async loginApi(ctx, data) {
      const res = await loginAPI(data)
      ctx.commit('LOGIN_TOKEN', res.data)
      return res
    }
  }
}
